const app = getApp()
Page({
  data: {
    nvabarData: {
      title: '首页', //导航栏 中间的标题   
    },

    avatarUrl: '/src/images/My_1.png',

    tabs: [],
    toView: 'item0',
    goodList: {
      item0: [
        {
          title: "哈密瓜",
          imgUrl: '/src/images/My_1.png',
          description: '又香又甜，好吃不贵，童叟无欺，巴拉拉巴拉巴拉',
          price: 13.9,
          oriPrice: 14.9
        },
        {
          title: "桃子",
          imgUrl: '/src/images/My_1.png',
          description: '又香又甜，好吃不贵，童叟无欺，巴拉拉巴拉巴拉',
          price: 200.9,
          oriPrice: 1000.9
        }
      ],
      item1: [{
        title: "哈密瓜",
        imgUrl: '/src/images/My_1.png',
        description: '又香又甜，好吃不贵，童叟无欺，巴拉拉巴拉巴拉',
        price: 15.9,
        oriPrice: 16.9
      }],
      item2: [{
        title: "哈密瓜",
        imgUrl: '/src/images/My_1.png',
        description: '又香又甜，好吃不贵，童叟无欺，巴拉拉巴拉巴拉',
        price: 17.9,
        oriPrice: 18.9
      }],
      item3: [{
        title: "哈密瓜",
        imgUrl: '/src/images/My_1.png',
        description: '又香又甜，好吃不贵，童叟无欺，巴拉拉巴拉巴拉',
        price: 19.9,
        oriPrice: 20.9
      }],
      item4: [{
        title: "哈密瓜",
        imgUrl: '/src/images/My_1.png',
        description: '又香又甜，好吃不贵，童叟无欺，巴拉拉巴拉巴拉',
        price: 21.9,
        oriPrice: 22.9
      }]
    }
  },

  // 卖家头像点击
  bindViewTap() {
    this.setData({ dialogShow: true })
  },

  onLoad() {
    this.setHeight()
    const title = ['首页', '外卖', '商超生鲜', '购物', '美食饮品', '生活服务', '休闲娱乐', '出行']
    const tabs = title.map((item, index) => ({ label: item, id: "item" + index }))
    this.setData({
      tabs
    })

  },
  setHeight: function () {
    let self = this
    let info = wx.getSystemInfoSync()
    let header = this.createSelectorQuery().select(".header")
    header.boundingClientRect(function (rect) {
      console.log(info.windowHeight, rect.height)
      self.setData({
        contentHieht: info.windowHeight - rect.height
      })
    }).exec()
    this.createSelectorQuery().select('.tabs').boundingClientRect(function (rect) {
      console.log(rect.height)
    }).exec()
  },

  onScrollChange(e) {
    console.log(e)
    this.setData({
      toView: 'item' + e.detail.index
    })
  },

  onScroll(e) {
    console.log(e)
  },

  addGood(e) {
    console.log(e)
  }
})